CREATE PROCEDURE coreRegistrySave
(
	@ID int output,
	@FK_ParentID int,
	@KeyName nvarchar(100),
	@KeyType int,
	@ValueString nvarchar(500)
)
AS
BEGIN

	IF @ID = -1
	BEGIN
		SET NOCOUNT ON;
		INSERT INTO registry (FK_ParentID, KeyName, KeyType, ValueString )
		VALUES (@FK_ParentID, @KeyName, @KeyType, @ValueString );
		SET NOCOUNT OFF;
		SELECT @ID = @@IDENTITY;
	END
	ELSE
	BEGIN
		UPDATE registry SET KeyName=@KeyName, KeyType=@KeyType, ValueString=@ValueString WHERE PK_ID =@ID;
	END

END